import os,time

system = int(input('请输入系统类型：\n1 Windows\n2 Linux/UNIX\n>>> '))

if system == 2:
	
    os.system('mkdir ~/.pip')
    print('已创建～/.pip/目录')
    os.system('touch ~/.pip/pip.conf')
    print('已创建~/.pip/pip.conf配置文件')
    homeDir = os.path.expanduser('~')
    cfgFile = open(homeDir+'/.pip/pip.conf','w')

    in0 = int(input('请选择镜像源：(输入序号选择)\n1 阿里云源\n2 清华源\n3 中科大源\n4 华工大源\n5 山工大源\n6 豆瓣源\n>>> '))

    if in0 == 1:
        print('[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/',file=cfgFile)
    if in0 == 2:
        print('[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple/',file=cfgFile)
    if in0 == 3:
        print('[global]\nindex-url = https://pypi.mirrors.ustc.edu.cn/simple/',file=cfgFile)
    if in0 == 4:
        print('[gloval]\nindex-url = http://pypi.hustunique.com/',file=cfgFile)
    if in0 == 5:
        print('[global]\nindex-url = http://pypi.sdutlinux.org/',file=cfgFile)
    if in0 == 6:
        print('[global]\nindex-url = http://pypi.douban.com/simple/',file=cfgFile)
        
    cfgFile.close()
        
    print('正在更新镜像源，请稍候，请勿退出')
    os.system('pip install pip --upgrade')
    os.system('pip3 install pip --upgrade')
    print('已完成')
    time.sleep(5)


if system == 1:
	
    os.system('mkdir %USERPROFILE%\\pip')
    print('已创建<UserHomeDir>\\pip目录')
    os.system('cd . > %USERPROFILE%\\pip\\pip.ini')
    print('已创建<UserHomeDir>\\pip\\pip.ini配置文件')
    homeDir = os.path.expanduser('~')
    iniFile = open(homeDir+'\\pip\\pip.ini','w')
    
    in0 = int(input('请选择镜像源：(输入序号选择)\n1 阿里云源\n2 清华源\n3 中科大源\n4 华工大源\n5 山工大源\n6 豆瓣源\n>>> '))

    if in0 == 1:
        print('[global]\nindex-url = http://mirrors.aliyun.com/pypi/simple/\n[install]\ntrusted-host = mirrors.aliyun.com',file=iniFile)
    if in0 == 2:
        print('[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple/\n[install]\ntrusted-host = pypi.tuna.tsinghua.edu.cn',file=iniFile)
    if in0 == 3:
        print('[global]\nindex-url = https://pypi.mirrors.ustc.edu.cn/simple/\n[install]\ntrusted-host = pypi.mirrors.ustc.edu.cn',file=iniFile)
    if in0 == 4:
        print('[gloval]\nindex-url = http://pypi.hustunique.com/\n[install]\ntrusted-host = pypi.hustunique.com',file=iniFile)
    if in0 == 5:
        print('[global]\nindex-url = http://pypi.sdutlinux.org/\n[install]\ntrusted-host = pypi.sdutlinux.org',file=iniFile)
    if in0 == 6:
        print('[global]\nindex-url = http://pypi.douban.com/simple/\n[install]\ntrusted-host = pypi.douban.com',file=iniFile)
        
    iniFile.close()
    
    print('正在更新镜像源，请稍候，请勿退出')
    os.system('pip install pip --upgrade')
    os.system('pip3 install pip --upgrade')
    print('已完成')
    time.sleep(5)
